home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / emacs-19.000 / emacs-19 / usr / local / info / emacs-18 < prev    next >
Encoding:
GNU Info File  |  1995-09-11  |  48.7 KB  |  1,145 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.55 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: Minor Modes,  Next: Variables,  Up: Customization
  6.  
  7. Minor Modes
  8. ===========
  9.  
  10.    Minor modes are optional features which you can turn on or off.  For
  11. example, Auto Fill mode is a minor mode in which SPC breaks lines
  12. between words as you type.  All the minor modes are independent of each
  13. other and of the selected major mode.  Most minor modes say in the mode
  14. line when they are on; for example, `Fill' in the mode line means that
  15. Auto Fill mode is on.
  16.  
  17.    Append `-mode' to the name of a minor mode to get the name of a
  18. command function that turns the mode on or off.  Thus, the command to
  19. enable or disable Auto Fill mode is called `M-x auto-fill-mode'.  These
  20. commands are usually invoked with `M-x', but you can bind keys to them
  21. if you wish.  With no argument, the function turns the mode on if it was
  22. off and off if it was on.  This is known as "toggling".  A positive
  23. argument always turns the mode on, and an explicit zero argument or a
  24. negative argument always turns it off.
  25.  
  26.    Enabling or disabling some minor modes applies only to the current
  27. buffer; each buffer is independent of the other buffers.  Therefore, you
  28. can enable the mode in particular buffers and disable it in others.  The
  29. per-buffer minor modes include Auto Fill mode, Auto Save mode, Font-Lock
  30. mode, ISO Accents mode, Outline minor mode, Overwrite mode, and Binary
  31. Overwrite mode.
  32.  
  33.    Auto Fill mode allows you to enter filled text without breaking lines
  34. explicitly.  Emacs inserts newlines as necessary to prevent lines from
  35. becoming too long.  *Note Filling::.
  36.  
  37.    Auto Save mode causes the contents of a buffer to be saved
  38. periodically to reduce the amount of work you can lose in case of a
  39. system crash.  *Note Auto Save::.
  40.  
  41.    Enriched mode enables editing and saving of formatted text.  *Note
  42. Formatted Text::.
  43.  
  44.    Font-Lock mode automatically highlights certain textual units found
  45. in programs, such as comments, strings, and function names being
  46. defined.  This requires a window system that can display multiple fonts.
  47. *Note Faces::.
  48.  
  49.    ISO Accents mode makes the characters ``', `'', `"', `^', `/' and
  50. `~' combine with the following letter, to produce an accented letter in
  51. the ISO Latin-1 character set.  *Note European Display::.
  52.  
  53.    Outline minor mode provides the same facilities as the major mode
  54. called Outline mode; but since it is a minor mode instead, you can
  55. combine it with any major mode.  *Note Outline Mode::.
  56.  
  57.    Overwrite mode causes ordinary printing characters to replace
  58. existing text instead of shoving it to the right.  For example, if
  59. point is in front of the `B' in `FOOBAR', then in Overwrite mode typing
  60. a `G' changes it to `FOOGAR', instead of producing it `FOOGBAR' as
  61. usual.  Binary Overwrite mode is a variant of Overwrite mode for
  62. editing binary files; it treats newlines and tabs like other
  63. characters, so that they overwrite other characters and can be
  64. overwritten by them.
  65.  
  66.    The following minor modes normally apply to all buffers at once.
  67. Since each is enabled or disabled by the value of a variable, you *can*
  68. set them differently for particular buffers, by explicitly making the
  69. corresponding variables local in those buffers.  *Note Locals::.
  70.  
  71.    Abbrev mode allows you to define abbreviations that automatically
  72. expand as you type them.  For example, `amd' might expand to `abbrev
  73. mode'.  *Note Abbrevs::, for full information.
  74.  
  75.    Icomplete mode displays an indication of available completions when
  76. you are in the minibuffer and completion is active.  *Note Completion
  77. Options::.
  78.  
  79.    Line Number mode enables continuous display in the mode line of the
  80. line number of point.  *Note Mode Line::.
  81.  
  82.    Resize-Minibuffer mode makes the minibuffer expand as necessary to
  83. hold the text that you put in it.  *Note Minibuffer Edit::.
  84.  
  85.    Scroll Bar mode gives each window a scroll bar (*note Scroll
  86. Bars::.).  Menu Bar mode gives each frame a menu bar (*note Menu
  87. Bars::.).  Both of these modes are enabled by default when you use the
  88. X Window System.
  89.  
  90.    In Transient Mark mode, every change in the buffer contents
  91. "deactivates" the mark, so that commands that operate on the region
  92. will get an error.  This means you must either set the mark, or
  93. explicitly "reactivate" it, before each command that uses the region.
  94. The advantage of Transient Mark mode is that Emacs can display the
  95. region highlighted (currently only when using X).  *Note Setting Mark::.
  96.  
  97.    For most minor modes, the command name is also the name of a variable
  98. which directly controls the mode.  The mode is enabled whenever this
  99. variable's value is non-`nil', and the minor mode command works by
  100. setting the variable.  For example, the command `outline-minor-mode'
  101. works by setting the value of `outline-minor-mode' as a variable; it is
  102. this variable that directly turns Outline minor mode on and off.  To
  103. check whether a given minor mode works this way, use `C-h v' to ask for
  104. documentation on the variable name.
  105.  
  106.    These minor mode variables provide a good way for Lisp programs to
  107. turn minor modes on and off; they are also useful in a file's local
  108. variables list.  But please think twice before setting minor modes with
  109. a local variables list, because most minor modes are matter of user
  110. preference--other users editing the same file might not want the same
  111. minor modes you prefer.
  112.  
  113. 
  114. File: emacs,  Node: Variables,  Next: Keyboard Macros,  Prev: Minor Modes,  Up: Customization
  115.  
  116. Variables
  117. =========
  118.  
  119.    A "variable" is a Lisp symbol which has a value.  The symbol's name
  120. is also called the name of the variable.  A variable name can contain
  121. any characters that can appear in a file, but conventionally variable
  122. names consist of words separated by hyphens.  A variable can have a
  123. documentation string which describes what kind of value it should have
  124. and how the value will be used.
  125.  
  126.    Lisp allows any variable to have any kind of value, but most
  127. variables that Emacs uses require a value of a certain type.  Often the
  128. value should always be a string, or should always be a number.
  129. Sometimes we say that a certain feature is turned on if a variable is
  130. "non-`nil'," meaning that if the variable's value is `nil', the feature
  131. is off, but the feature is on for *any* other value.  The conventional
  132. value to use to turn on the feature--since you have to pick one
  133. particular value when you set the variable--is `t'.
  134.  
  135.    Emacs uses many Lisp variables for internal record keeping, as any
  136. Lisp program must, but the most interesting variables for you are the
  137. ones that exist for the sake of customization.  Emacs does not
  138. (usually) change the values of these variables; instead, you set the
  139. values, and thereby alter and control the behavior of certain Emacs
  140. commands.  These variables are called "options".  Most options are
  141. documented in this manual, and appear in the Variable Index (*note
  142. Variable Index::.).
  143.  
  144.    One example of a variable which is an option is `fill-column', which
  145. specifies the position of the right margin (as a number of characters
  146. from the left margin) to be used by the fill commands (*note
  147. Filling::.).
  148.  
  149. * Menu:
  150.  
  151. * Examining::         Examining or setting one variable's value.
  152. * Edit Options::     Examining or editing list of all variables' values.
  153. * Hooks::         Hook variables let you specify programs for parts
  154.                of Emacs to run on particular occasions.
  155. * Locals::         Per-buffer values of variables.
  156. * File Variables::   How files can specify variable values.
  157.  
  158. 
  159. File: emacs,  Node: Examining,  Next: Edit Options,  Up: Variables
  160.  
  161. Examining and Setting Variables
  162. -------------------------------
  163.  
  164. `C-h v VAR RET'
  165.      Display the value and documentation of variable VAR
  166.      (`describe-variable').
  167.  
  168. `M-x set-variable RET VAR RET VALUE RET'
  169.      Change the value of variable VAR to VALUE.
  170.  
  171.    To examine the value of a single variable, use `C-h v'
  172. (`describe-variable'), which reads a variable name using the
  173. minibuffer, with completion.  It displays both the value and the
  174. documentation of the variable.  For example,
  175.  
  176.      C-h v fill-column RET
  177.  
  178. displays something like this:
  179.  
  180.      fill-column's value is 75
  181.      
  182.      Documentation:
  183.      *Column beyond which automatic line-wrapping should happen.
  184.      Automatically becomes buffer-local when set in any fashion.
  185.  
  186. The star at the beginning of the documentation indicates that this
  187. variable is an option.  `C-h v' is not restricted to options; it allows
  188. any variable name.
  189.  
  190.    The most convenient way to set a specific option is with `M-x
  191. set-variable'.  This reads the variable name with the minibuffer (with
  192. completion), and then reads a Lisp expression for the new value using
  193. the minibuffer a second time.  For example,
  194.  
  195.      M-x set-variable RET fill-column RET 75 RET
  196.  
  197. sets `fill-column' to 75.
  198.  
  199.    You can set any variable with a Lisp expression using the function
  200. `setq'.  Here's how to use it to set `fill-column':
  201.  
  202.      (setq fill-column 75)
  203.  
  204.    Setting variables, like all means of customizing Emacs except where
  205. otherwise stated, affects only the current Emacs session.
  206.  
  207. 
  208. File: emacs,  Node: Edit Options,  Next: Hooks,  Prev: Examining,  Up: Variables
  209.  
  210. Editing Variable Values
  211. -----------------------
  212.  
  213.    These two functions make it easy to display all the Emacs option
  214. variables, and to change some of them if you wish.
  215.  
  216. `M-x list-options'
  217.      Display a buffer listing names, values and documentation of all
  218.      options.
  219.  
  220. `M-x edit-options'
  221.      Change option values by editing a list of options.
  222.  
  223.    `M-x list-options' displays a list of all Emacs option variables, in
  224. an Emacs buffer named `*List Options*'.  Each option is shown with its
  225. documentation and its current value.  Here is what a portion of it might
  226. look like:
  227.  
  228.      ;; exec-path:
  229.      ("." "/usr/local/bin" "/usr/ucb" "/bin" "/usr/bin" "/u2/emacs/etc")
  230.      *List of directories to search programs to run in subprocesses.
  231.      Each element is a string (directory name)
  232.      or nil (try the default directory).
  233.      ;;
  234.      ;; fill-column:
  235.      75
  236.      *Column beyond which automatic line-wrapping should happen.
  237.      Automatically becomes buffer-local when set in any fashion.
  238.      ;;
  239.  
  240.    `M-x edit-options' goes one step further and immediately selects the
  241. `*List Options*' buffer; this buffer uses the major mode Options mode,
  242. which provides commands that allow you to point at an option and change
  243. its value:
  244.  
  245. `s'
  246.      Set the variable point is in or near to a new value read using the
  247.      minibuffer.
  248.  
  249. `x'
  250.      Toggle the variable point is in or near: if the value was `nil',
  251.      it becomes `t'; otherwise it becomes `nil'.
  252.  
  253. `1'
  254.      Set the variable point is in or near to `t'.
  255.  
  256. `0'
  257.      Set the variable point is in or near to `nil'.
  258.  
  259. `n'
  260. `p'
  261.      Move to the next or previous variable.
  262.  
  263.    Any changes take effect immediately, and last until you exit from
  264. Emacs.
  265.  
  266. 
  267. File: emacs,  Node: Hooks,  Next: Locals,  Prev: Edit Options,  Up: Variables
  268.  
  269. Hooks
  270. -----
  271.  
  272.    A "hook" is a variable where you can store a function or functions
  273. to be called on a particular occasion by an existing program.  Emacs
  274. provides a number of hooks for the sake of customization.
  275.  
  276.    Most of the hooks in Emacs are "normal hooks".  These variables
  277. contain lists of functions to be called with no arguments.  The reason
  278. most hooks are normal hooks is so that you can use them in a uniform
  279. way.  Every variable in Emacs whose name ends in `-hook' is a normal
  280. hook.
  281.  
  282.    Most major modes run hooks as the last step of initialization.  This
  283. makes it easy for a user to customize the behavior of the mode, by
  284. overriding the local variable assignments already made by the mode.  But
  285. hooks may also be used in other contexts.  For example, the hook
  286. `suspend-hook' runs just before Emacs suspends itself (*note
  287. Exiting::.).
  288.  
  289.    The recommended way to add a hook function to a normal hook is by
  290. calling `add-hook'.  You can use any valid Lisp function as the hook
  291. function.  For example, here's how to set up a hook to turn on Auto
  292. Fill mode when entering Text mode and other modes based on Text mode:
  293.  
  294.      (add-hook 'text-mode-hook 'turn-on-auto-fill)
  295.  
  296.    The next example shows how to use a hook to customize the indentation
  297. of C code.  (People often have strong personal preferences for one
  298. format compared to another.)  Here the hook function is an anonymous
  299. lambda expression.
  300.  
  301.      (add-hook 'c-mode-hook
  302.        (function (lambda ()
  303.                    (setq c-indent-level 4
  304.                          c-argdecl-indent 0
  305.                          c-label-offset -4
  306.                          c-continued-statement-indent 0
  307.                          c-brace-offset 0
  308.                          comment-column 40))))
  309.      
  310.      (setq c++-mode-hook c-mode-hook)
  311.  
  312.    It is best to design your hook functions so that the order in which
  313. they are executed does not matter.  Any dependence on the order is
  314. "asking for trouble."  However, the order is predictable: the most
  315. recently added hook functions are executed first.
  316.  
  317. 
  318. File: emacs,  Node: Locals,  Next: File Variables,  Prev: Hooks,  Up: Variables
  319.  
  320. Local Variables
  321. ---------------
  322.  
  323. `M-x make-local-variable RET VAR RET'
  324.      Make variable VAR have a local value in the current buffer.
  325.  
  326. `M-x kill-local-variable RET VAR RET'
  327.      Make variable VAR use its global value in the current buffer.
  328.  
  329. `M-x make-variable-buffer-local RET VAR RET'
  330.      Mark variable VAR so that setting it will make it local to the
  331.      buffer that is current at that time.
  332.  
  333.    Almost any variable can be made "local" to a specific Emacs buffer.
  334. This means that its value in that buffer is independent of its value in
  335. other buffers.  A few variables are always local in every buffer.
  336. Every other Emacs variable has a "global" value which is in effect in
  337. all buffers that have not made the variable local.
  338.  
  339.    `M-x make-local-variable' reads the name of a variable and makes it
  340. local to the current buffer.  Further changes in this buffer will not
  341. affect others, and further changes in the global value will not affect
  342. this buffer.
  343.  
  344.    `M-x make-variable-buffer-local' reads the name of a variable and
  345. changes the future behavior of the variable so that it will become local
  346. automatically when it is set.  More precisely, once a variable has been
  347. marked in this way, the usual ways of setting the variable automatically
  348. do `make-local-variable' first.  We call such variables "per-buffer"
  349. variables.
  350.  
  351.    Major modes (*note Major Modes::.) always make variables local to the
  352. buffer before setting the variables.  This is why changing major modes
  353. in one buffer has no effect on other buffers.  Minor modes also work by
  354. setting variables--normally, each minor mode has one controlling
  355. variable which is non-`nil' when the mode is enabled (*note Minor
  356. Modes::.).  For most minor modes, the controlling variable is per
  357. buffer.
  358.  
  359.    Emacs contains a number of variables that are always per-buffer.
  360. These include `abbrev-mode', `auto-fill-function', `case-fold-search',
  361. `comment-column', `ctl-arrow', `fill-column', `fill-prefix',
  362. `indent-tabs-mode', `left-margin', `mode-line-format', `overwrite-mode',
  363. `selective-display-ellipses', `selective-display', `tab-width', and
  364. `truncate-lines'.  Some other variables are always local in every
  365. buffer, but they are used for internal purposes.
  366.  
  367.    A few variables cannot be local to a buffer because they are always
  368. local to each display instead (*Note Multiple Displays::).  If you try
  369. to make one of these variables buffer-local, you'll get an error
  370. message.
  371.  
  372.    `M-x kill-local-variable' reads the name of a variable and makes it
  373. cease to be local to the current buffer.  The global value of the
  374. variable henceforth is in effect in this buffer.  Setting the major mode
  375. kills all the local variables of the buffer except for a few variables
  376. specially marked as "permanent locals".
  377.  
  378.    To set the global value of a variable, regardless of whether the
  379. variable has a local value in the current buffer, you can use the Lisp
  380. construct `setq-default'.  This construct is used just like `setq', but
  381. it sets variables' global values instead of their local values (if
  382. any).  When the current buffer does have a local value, the new global
  383. value may not be visible until you switch to another buffer.  Here is
  384. an example:
  385.  
  386.      (setq-default fill-column 75)
  387.  
  388. `setq-default' is the only way to set the global value of a variable
  389. that has been marked with `make-variable-buffer-local'.
  390.  
  391.    Lisp programs can use `default-value' to look at a variable's
  392. default value.  This function takes a symbol as argument and returns its
  393. default value.  The argument is evaluated; usually you must quote it
  394. explicitly.  For example, here's how to obtain the default value of
  395. `fill-column':
  396.  
  397.      (default-value 'fill-column)
  398.  
  399. 
  400. File: emacs,  Node: File Variables,  Prev: Locals,  Up: Variables
  401.  
  402. Local Variables in Files
  403. ------------------------
  404.  
  405.    A file can specify local variable values for use when you edit the
  406. file with Emacs.  Visiting the file checks for local variables
  407. specifications; it automatically makes these variables local to the
  408. buffer, and sets them to the values specified in the file.
  409.  
  410.    There are two ways to specify local variable values: in the first
  411. line, or with a local variables list.  Here's how to specify them in the
  412. first line:
  413.  
  414.      -*- mode: MODENAME; VAR: VALUE; ... -*-
  415.  
  416. You can specify any number of variables/value pairs in this way, each
  417. pair with a colon and semicolon as shown above.  `mode: MODENAME;'
  418. specifies the major mode; this should come first in the line.  The
  419. VALUEs are not evaluated; they are used literally.  Here is an example
  420. that specifies Lisp mode and sets two variables with numeric values:
  421.  
  422.      ;; -*-mode: Lisp; fill-column: 75; comment-column: 50; -*-
  423.  
  424.    A "local variables list" goes near the end of the file, in the last
  425. page.  (It is often best to put it on a page by itself.)  The local
  426. variables list starts with a line containing the string `Local
  427. Variables:', and ends with a line containing the string `End:'.  In
  428. between come the variable names and values, one set per line, as
  429. `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
  430. literally.  If a file has both a local variables list and a `-*-' line,
  431. Emacs processes *everything* in the `-*-' line first, and *everything*
  432. in the local variables list afterward.
  433.  
  434.    Here is an example of a local variables list:
  435.  
  436.      ;;; Local Variables: ***
  437.      ;;; mode:lisp ***
  438.      ;;; comment-column:0 ***
  439.      ;;; comment-start: ";;; "  ***
  440.      ;;; comment-end:"***" ***
  441.      ;;; End: ***
  442.  
  443.    As you see, each line starts with the prefix `;;; ' and each line
  444. ends with the suffix ` ***'.  Emacs recognizes these as the prefix and
  445. suffix based on the first line of the list, by finding them surrounding
  446. the magic string `Local Variables:'; then it automatically discards
  447. them from the other lines of the list.
  448.  
  449.    The usual reason for using a prefix and/or suffix is to embed the
  450. local variables list in a comment, so it won't confuse other programs
  451. that the file is intended as input for.  The example above is for a
  452. language where comment lines start with `;;; ' and end with `***'; the
  453. local values for `comment-start' and `comment-end' customize the rest
  454. of Emacs for this unusual syntax.  Don't use a prefix (or a suffix) if
  455. you don't need one.
  456.  
  457.    Two "variable names" have special meanings in a local variables
  458. list: a value for the variable `mode' really sets the major mode, and a
  459. value for the variable `eval' is simply evaluated as an expression and
  460. the value is ignored.  `mode' and `eval' are not real variables;
  461. setting variables named `mode' and `eval' in any other context has no
  462. special meaning.  If `mode' is used to set a major mode, it should be
  463. the first "variable" in the list.
  464.  
  465.    You can use the `mode' "variable" to set minor modes as well as
  466. major modes; in fact, you can use it more than once, first to set the
  467. major mode and then to set minor modes which are specific to particular
  468. buffers.  But most minor modes should not be specified in the file in
  469. any fashion, because they represent user preferences.  For example, you
  470. should not try to specify Auto Fill mode with file local variables,
  471. because whether to use Auto Fill mode for editing a particular kind of
  472. text is a matter of personal taste, not an aspect of the format of the
  473. text.
  474.  
  475.    The start of the local variables list must be no more than 3000
  476. characters from the end of the file, and must be in the last page if the
  477. file is divided into pages.  Otherwise, Emacs will not notice it is
  478. there.  The purpose of this rule is so that a stray `Local Variables:'
  479. not in the last page does not confuse Emacs, and so that visiting a
  480. long file that is all one page and has no local variables list need not
  481. take the time to search the whole file.
  482.  
  483.    You may be tempted to try to turn on Auto Fill mode with a local
  484. variable list.  That is a mistake.  The choice of Auto Fill mode or not
  485. is a matter of individual taste, not a matter of the contents of
  486. particular files.  If you want to use Auto Fill, set up major mode
  487. hooks with your `.emacs' file to turn it on (when appropriate) for you
  488. alone (*note Init File::.).  Don't try to use a local variable list
  489. that would impose your taste on everyone.
  490.  
  491.    The variable `enable-local-variables' controls whether to process
  492. local variables lists, and thus gives you a chance to override them.
  493. Its default value is `t', which means do process local variables lists.
  494. If you set the value to `nil', Emacs simply ignores local variables
  495. lists.  Any other value says to query you about each local variables
  496. list, showing you the local variables list to consider.
  497.  
  498.    The `eval' "variable", and certain actual variables, create a
  499. special risk; when you visit someone else's file, local variable
  500. specifications for these could affect your Emacs in arbitrary ways.
  501. Therefore, the option `enable-local-eval' controls whether Emacs
  502. processes `eval' variables, as well variables with names that end in
  503. `-hook', `-hooks', `-function' or `-functions', and certain other
  504. variables.  The three possibilities for the option's value are `t',
  505. `nil', and anything else, just as for `enable-local-variables'.  The
  506. default is `maybe', which is neither `t' nor `nil', so normally Emacs
  507. does ask for confirmation about file settings for these variables.
  508.  
  509.    Use the command `normal-mode' to reset the local variables and major
  510. mode of a buffer according to the file name and contents, including the
  511. local variables list if any.  *Note Choosing Modes::.
  512.  
  513. 
  514. File: emacs,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
  515.  
  516. Keyboard Macros
  517. ===============
  518.  
  519.    A "keyboard macro" is a command defined by the user to stand for
  520. another sequence of keys.  For example, if you discover that you are
  521. about to type `C-n C-d' forty times, you can speed your work by
  522. defining a keyboard macro to do `C-n C-d' and calling it with a repeat
  523. count of forty.
  524.  
  525. `C-x ('
  526.      Start defining a keyboard macro (`start-kbd-macro').
  527.  
  528. `C-x )'
  529.      End the definition of a keyboard macro (`end-kbd-macro').
  530.  
  531. `C-x e'
  532.      Execute the most recent keyboard macro (`call-last-kbd-macro').
  533.  
  534. `C-u C-x ('
  535.      Re-execute last keyboard macro, then add more keys to its
  536.      definition.
  537.  
  538. `C-x q'
  539.      When this point is reached during macro execution, ask for
  540.      confirmation (`kbd-macro-query').
  541.  
  542. `M-x name-last-kbd-macro'
  543.      Give a command name (for the duration of the session) to the most
  544.      recently defined keyboard macro.
  545.  
  546. `M-x insert-kbd-macro'
  547.      Insert in the buffer a keyboard macro's definition, as Lisp code.
  548.  
  549. `C-x C-k'
  550.      Edit a previously defined keyboard macro (`edit-kbd-macro').
  551.  
  552.    Keyboard macros differ from ordinary Emacs commands in that they are
  553. written in the Emacs command language rather than in Lisp.  This makes
  554. it easier for the novice to write them, and makes them more convenient
  555. as temporary hacks.  However, the Emacs command language is not powerful
  556. enough as a programming language to be useful for writing anything
  557. intelligent or general.  For such things, Lisp must be used.
  558.  
  559.    You define a keyboard macro while executing the commands which are
  560. the definition.  Put differently, as you define a keyboard macro, the
  561. definition is being executed for the first time.  This way, you can see
  562. what the effects of your commands are, so that you don't have to figure
  563. them out in your head.  When you are finished, the keyboard macro is
  564. defined and also has been, in effect, executed once.  You can then do
  565. the whole thing over again by invoking the macro.
  566.  
  567. * Menu:
  568.  
  569. * Basic Kbd Macro::  Defining and running keyboard macros.
  570. * Save Kbd Macro::   Giving keyboard macros names; saving them in files.
  571. * Kbd Macro Query::  Keyboard macros that do different things each use.
  572.  
  573. 
  574. File: emacs,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Up: Keyboard Macros
  575.  
  576. Basic Use
  577. ---------
  578.  
  579.    To start defining a keyboard macro, type the `C-x (' command
  580. (`start-kbd-macro').  From then on, your keys continue to be executed,
  581. but also become part of the definition of the macro.  `Def' appears in
  582. the mode line to remind you of what is going on.  When you are
  583. finished, the `C-x )' command (`end-kbd-macro') terminates the
  584. definition (without becoming part of it!).  For example,
  585.  
  586.      C-x ( M-f foo C-x )
  587.  
  588. defines a macro to move forward a word and then insert `foo'.
  589.  
  590.    The macro thus defined can be invoked again with the `C-x e' command
  591. (`call-last-kbd-macro'), which may be given a repeat count as a numeric
  592. argument to execute the macro many times.  `C-x )' can also be given a
  593. repeat count as an argument, in which case it repeats the macro that
  594. many times right after defining it, but defining the macro counts as
  595. the first repetition (since it is executed as you define it).
  596. Therefore, giving `C-x )' an argument of 4 executes the macro
  597. immediately 3 additional times.  An argument of zero to `C-x e' or `C-x
  598. )' means repeat the macro indefinitely (until it gets an error or you
  599. type `C-g').
  600.  
  601.    If you wish to repeat an operation at regularly spaced places in the
  602. text, define a macro and include as part of the macro the commands to
  603. move to the next place you want to use it.  For example, if you want to
  604. change each line, you should position point at the start of a line, and
  605. define a macro to change that line and leave point at the start of the
  606. next line.  Then repeating the macro will operate on successive lines.
  607.  
  608.    After you have terminated the definition of a keyboard macro, you
  609. can add to the end of its definition by typing `C-u C-x ('.  This is
  610. equivalent to plain `C-x (' followed by retyping the whole definition
  611. so far.  As a consequence it re-executes the macro as previously
  612. defined.
  613.  
  614.    You can use function keys in a keyboard macro, just like keyboard
  615. keys.  You can even use mouse events, but be careful about that: when
  616. the macro replays the mouse event, it uses the original mouse position
  617. of that event, the position that the mouse had while you were defining
  618. the macro.  The effect of this may be hard to predict.  (Using the
  619. current mouse position would be even less predictable.)
  620.  
  621.    One thing that doesn't always work well in a keyboard macro is the
  622. command `C-M-c' (`exit-recursive-edit').  When this command exits a
  623. recursive edit that started within the macro, it works as you'd expect.
  624. But if it exits a recursive edit that started before you invoked the
  625. keyboard macro, it also necessarily exits the keyboard macro as part of
  626. the process.
  627.  
  628.    You can edit a keyboard macro already defined by typing `C-x C-k'
  629. (`edit-kbd-macro').  Follow that with the keyboard input that you would
  630. use to invoke the macro--`C-x e' or `M-x NAME' or some other key
  631. sequence.  This formats the macro definition in a buffer and enters a
  632. specialized major mode for editing it.  Type `C-h m' once in that
  633. buffer to display details of how to edit the macro.  When you are
  634. finished editing, type `C-c C-c'.
  635.  
  636. 
  637. File: emacs,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
  638.  
  639. Naming and Saving Keyboard Macros
  640. ---------------------------------
  641.  
  642.    If you wish to save a keyboard macro for longer than until you
  643. define the next one, you must give it a name using `M-x
  644. name-last-kbd-macro'.  This reads a name as an argument using the
  645. minibuffer and defines that name to execute the macro.  The macro name
  646. is a Lisp symbol, and defining it in this way makes it a valid command
  647. name for calling with `M-x' or for binding a key to with
  648. `global-set-key' (*note Keymaps::.).  If you specify a name that has a
  649. prior definition other than another keyboard macro, an error message is
  650. printed and nothing is changed.
  651.  
  652.    Once a macro has a command name, you can save its definition in a
  653. file.  Then it can be used in another editing session.  First, visit
  654. the file you want to save the definition in.  Then use this command:
  655.  
  656.      M-x insert-kbd-macro RET MACRONAME RET
  657.  
  658. This inserts some Lisp code that, when executed later, will define the
  659. same macro with the same definition it has now.  (You need not
  660. understand Lisp code to do this, because `insert-kbd-macro' writes the
  661. Lisp code for you.)  Then save the file.  You can load the file later
  662. with `load-file' (*note Lisp Libraries::.).  If the file you save in is
  663. your init file `~/.emacs' (*note Init File::.) then the macro will be
  664. defined each time you run Emacs.
  665.  
  666.    If you give `insert-kbd-macro' a numeric argument, it makes
  667. additional Lisp code to record the keys (if any) that you have bound to
  668. the keyboard macro, so that the macro will be reassigned the same keys
  669. when you load the file.
  670.  
  671. 
  672. File: emacs,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
  673.  
  674. Executing Macros with Variations
  675. --------------------------------
  676.  
  677.    Using `C-x q' (`kbd-macro-query'), you can get an effect similar to
  678. that of `query-replace', where the macro asks you each time around
  679. whether to make a change.  While defining the macro, type `C-x q' at
  680. the point where you want the query to occur.  During macro definition,
  681. the `C-x q' does nothing, but when you run the macro later, `C-x q'
  682. asks you interactively whether to continue.
  683.  
  684.    The valid responses when `C-x q' asks are SPC (or `y'), DEL (or
  685. `n'), ESC (or `q'), `C-l' and `C-r'.  The answers are the same as in
  686. `query-replace', though not all of the `query-replace' options are
  687. meaningful.
  688.  
  689.    These responses include SPC to continue, and DEL to skip the
  690. remainder of this repetition of the macro and start right away with the
  691. next repetition.  ESC means to skip the remainder of this repetition
  692. and cancel further repetitions.  `C-l' redraws the screen and asks you
  693. again for a character to say what to do.
  694.  
  695.    `C-r' enters a recursive editing level, in which you can perform
  696. editing which is not part of the macro.  When you exit the recursive
  697. edit using `C-M-c', you are asked again how to continue with the
  698. keyboard macro.  If you type a SPC at this time, the rest of the macro
  699. definition is executed.  It is up to you to leave point and the text in
  700. a state such that the rest of the macro will do what you want.
  701.  
  702.    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
  703. completely different function.  It enters a recursive edit reading
  704. input from the keyboard, both when you type it during the definition of
  705. the macro, and when it is executed from the macro.  During definition,
  706. the editing you do inside the recursive edit does not become part of
  707. the macro.  During macro execution, the recursive edit gives you a
  708. chance to do some particularized editing on each repetition.  *Note
  709. Recursive Edit::.
  710.  
  711. 
  712. File: emacs,  Node: Key Bindings,  Next: Keyboard Translations,  Prev: Keyboard Macros,  Up: Customization
  713.  
  714. Customizing Key Bindings
  715. ========================
  716.  
  717.    This section describes "key bindings" which map keys to commands,
  718. and the "keymaps" which record key bindings.  It also explains how to
  719. customize key bindings.
  720.  
  721.    Recall that a command is a Lisp function whose definition provides
  722. for interactive use.  Like every Lisp function, a command has a function
  723. name which usually consists of lower case letters and hyphens.
  724.  
  725. * Menu:
  726.  
  727. * Keymaps::          Generalities.  The global keymap.
  728. * Prefix Keymaps::   Keymaps for prefix keys.
  729. * Local Keymaps::    Major and minor modes have their own keymaps.
  730. * Minibuffer Maps::  The minibuffer uses its own local keymaps.
  731. * Rebinding::        How to redefine one key's meaning conveniently.
  732. * Init Rebinding::   Rebinding keys with your init file, `.emacs'.
  733. * Function Keys::    Rebinding terminal function keys.
  734. * Named ASCII Chars::Distinguishing TAB from `C-i', and so on.
  735. * Mouse Buttons::    Rebinding mouse buttons in Emacs.
  736. * Disabling::        Disabling a command means confirmation is required
  737.                        before it can be executed.  This is done to protect
  738.                        beginners from surprises.
  739.  
  740. 
  741. File: emacs,  Node: Keymaps,  Next: Prefix Keymaps,  Up: Key Bindings
  742.  
  743. Keymaps
  744. -------
  745.  
  746.    The bindings between key sequences and command functions are recorded
  747. in data structures called "keymaps".  Emacs has many of these, each
  748. used on particular occasions.
  749.  
  750.    Recall that a "key sequence" ("key", for short) is a sequence of
  751. "input events" that have a meaning as a unit.  Input events include
  752. characters, function keys and mouse buttons--all the inputs that you
  753. can send to the computer with your terminal.  A key sequence gets its
  754. meaning from its "binding", which says what command it runs.  The
  755. function of keymaps is to record these bindings.
  756.  
  757.    The "global" keymap is the most important keymap because it is
  758. always in effect.  The global keymap defines keys for Fundamental mode;
  759. most of these definitions are common to most or all major modes.  Each
  760. major or minor mode can have its own keymap which overrides the global
  761. definitions of some keys.
  762.  
  763.    For example, a self-inserting character such as `g' is
  764. self-inserting because the global keymap binds it to the command
  765. `self-insert-command'.  The standard Emacs editing characters such as
  766. `C-a' also get their standard meanings from the global keymap.
  767. Commands to rebind keys, such as `M-x global-set-key', actually work by
  768. storing the new binding in the proper place in the global map.  *Note
  769. Rebinding::.
  770.  
  771.    Meta characters work differently; Emacs translates each Meta
  772. character into a pair of characters starting with ESC.  When you type
  773. the character `M-a' in a key sequence, Emacs replaces it with `ESC a'.
  774. A meta key comes in as a single input event, but becomes two events for
  775. purposes of key bindings.  The reason for this is historical, and we
  776. might change it someday.
  777.  
  778.    Most modern keyboards have function keys as well as character keys.
  779. Function keys send input events just as character keys do, and keymaps
  780. can have bindings for them.
  781.  
  782.    On many terminals, typing a function key actually sends the computer
  783. a sequence of characters; the precise details of the sequence depends on
  784. which function key and on the model of terminal you are using.  (Often
  785. the sequence starts with `ESC ['.)  If Emacs understands your terminal
  786. type properly, it recognizes the character sequences forming function
  787. keys wherever they occur in a key sequence (not just at the beginning).
  788. Thus, for most purposes, you can pretend the function keys reach Emacs
  789. directly and ignore their encoding as character sequences.
  790.  
  791.    Mouse buttons also produce input events.  These events come with
  792. other data--the window and position where you pressed or released the
  793. button, and a time stamp.  But only the choice of button matters for key
  794. bindings; the other data matters only if a command looks at it.
  795. (Commands designed for mouse invocation usually do look at the other
  796. data.)
  797.  
  798.    A keymap records definitions for single events.  Interpreting a key
  799. sequence of multiple events involves a chain of keymaps.  The first
  800. keymap gives a definition for the first event; this definition is
  801. another keymap, which is used to look up the second event in the
  802. sequence, and so on.
  803.  
  804.    Key sequences can mix function keys and characters.  For example,
  805. `C-x SELECT' makes sense.  If you make SELECT a prefix key, then
  806. `SELECT C-n' makes sense.  You can even mix mouse events with keyboard
  807. events, but we recommend against it, because such sequences are
  808. inconvenient to type in.
  809.  
  810. 
  811. File: emacs,  Node: Prefix Keymaps,  Next: Local Keymaps,  Prev: Keymaps,  Up: Key Bindings
  812.  
  813. Prefix Keymaps
  814. --------------
  815.  
  816.    A prefix key such as `C-x' or ESC has its own keymap, which holds
  817. the definition for the event that immediately follows that prefix.
  818.  
  819.    The definition of a prefix key is usually the keymap to use for
  820. looking up the following event.  The definition can also be a Lisp
  821. symbol whose function definition is the following keymap; the effect is
  822. the same, but it provides a command name for the prefix key that can be
  823. used as a description of what the prefix key is for.  Thus, the binding
  824. of `C-x' is the symbol `Ctl-X-Prefix', whose function definition is the
  825. keymap for `C-x' commands.  The definitions of `C-c', `C-x', `C-h' and
  826. ESC as prefix keys appear in the global map, so these prefix keys are
  827. always available.
  828.  
  829.    Some prefix keymaps are stored in variables with names:
  830.  
  831.    * `ctl-x-map' is the variable name for the map used for characters
  832.      that follow `C-x'.
  833.  
  834.    * `help-map' is for characters that follow `C-h'.
  835.  
  836.    * `esc-map' is for characters that follow ESC.  Thus, all Meta
  837.      characters are actually defined by this map.
  838.  
  839.    * `ctl-x-4-map' is for characters that follow `C-x 4'.
  840.  
  841.    * `mode-specific-map' is for characters that follow `C-c'.
  842.  
  843. 
  844. File: emacs,  Node: Local Keymaps,  Next: Minibuffer Maps,  Prev: Prefix Keymaps,  Up: Key Bindings
  845.  
  846. Local Keymaps
  847. -------------
  848.  
  849.    So far we have explained the ins and outs of the global map.  Major
  850. modes customize Emacs by providing their own key bindings in "local
  851. keymaps".  For example, C mode overrides TAB to make it indent the
  852. current line for C code.  Portions of text in the buffer can specify
  853. their own keymaps to substitute for the keymap of the buffer's major
  854. mode.
  855.  
  856.    Minor modes can also have local keymaps.  Whenever a minor mode is
  857. in effect, the definitions in its keymap override both the major mode's
  858. local keymap and the global keymap.
  859.  
  860.    The local keymaps for Lisp mode, C mode, and several other major
  861. modes always exist even when not in use.  These are kept in variables
  862. named `lisp-mode-map', `c-mode-map', and so on.  For major modes less
  863. often used, the local keymap is normally constructed only when the mode
  864. is used for the first time in a session.  This is to save space.  If
  865. you wish to change one of these keymaps, you must use the major mode's
  866. "mode hook"--see below.
  867.  
  868.    All minor mode keymaps are created in advance.  There is no way to
  869. defer their creation until the first time the minor mode is enabled.
  870.  
  871.    A local keymap can locally redefine a key as a prefix key by defining
  872. it as a prefix keymap.  If the key is also defined globally as a prefix,
  873. then its local and global definitions (both keymaps) effectively
  874. combine: both of them are used to look up the event that follows the
  875. prefix key.  Thus, if the mode's local keymap defines `C-c' as another
  876. keymap, and that keymap defines `C-z' as a command, this provides a
  877. local meaning for `C-c C-z'.  This does not affect other sequences that
  878. start with `C-c'; if those sequences don't have their own local
  879. bindings, their global bindings remain in effect.
  880.  
  881.    Another way to think of this is that Emacs handles a multi-event key
  882. sequence by looking in several keymaps, one by one, for a binding of the
  883. whole key sequence.  First it checks the minor mode keymaps for minor
  884. modes that are enabled, then it checks the major mode's keymap, and then
  885. it checks the global keymap.  This is not precisely how key lookup
  886. works, but it's good enough for understanding ordinary circumstances.
  887.  
  888.    To change the local bindings of a major mode, you must change the
  889. mode's local keymap.  Normally you must wait until the first time the
  890. mode is used, because most major modes don't create their keymaps until
  891. then.  If you want to specify something in your `~/.emacs' file to
  892. change a major mode's bindings, you must use the mode's mode hook to
  893. delay the change until the mode is first used.
  894.  
  895.    For example, the command `texinfo-mode' to select Texinfo mode runs
  896. the hook `texinfo-mode-hook'.  Here's how you can use the hook to add
  897. local bindings (not very useful, we admit) for `C-c n' and `C-c p' in
  898. Texinfo mode:
  899.  
  900.      (add-hook 'texinfo-mode-hook
  901.                '(lambda ()
  902.                   (define-key texinfo-mode-map
  903.                               "\C-cp"
  904.                               'backward-paragraph)
  905.                   (define-key texinfo-mode-map
  906.                               "\C-cn"
  907.                               'forward-paragraph)
  908.                   ))
  909.  
  910.    *Note Hooks::.
  911.  
  912. 
  913. File: emacs,  Node: Minibuffer Maps,  Next: Rebinding,  Prev: Local Keymaps,  Up: Key Bindings
  914.  
  915. Minibuffer Keymaps
  916. ------------------
  917.  
  918.    The minibuffer has its own set of local keymaps; they contain various
  919. completion and exit commands.
  920.  
  921.    * `minibuffer-local-map' is used for ordinary input (no completion).
  922.  
  923.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  924.      like RET.  This is used mainly for Mocklisp compatibility.
  925.  
  926.    * `minibuffer-local-completion-map' is for permissive completion.
  927.  
  928.    * `minibuffer-local-must-match-map' is for strict completion and for
  929.      cautious completion.
  930.  
  931. 
  932. File: emacs,  Node: Rebinding,  Next: Init Rebinding,  Prev: Minibuffer Maps,  Up: Key Bindings
  933.  
  934. Changing Key Bindings Interactively
  935. -----------------------------------
  936.  
  937.    The way to redefine an Emacs key is to change its entry in a keymap.
  938. You can change the global keymap, in which case the change is effective
  939. in all major modes (except those that have their own overriding local
  940. definitions for the same key).  Or you can change the current buffer's
  941. local map, which affects all buffers using the same major mode.
  942.  
  943. `M-x global-set-key RET KEY CMD RET'
  944.      Define KEY globally to run CMD.
  945.  
  946. `M-x local-set-key RET KEY CMD RET'
  947.      Define KEY locally (in the major mode now in effect) to run CMD.
  948.  
  949. `M-x global-unset-key RET KEY'
  950.      Make KEY undefined in the global map.
  951.  
  952. `M-x local-unset-key RET KEY'
  953.      Make KEY undefined locally (in the major mode now in effect).
  954.  
  955.    For example, suppose you like to execute commands in a subshell
  956. within an Emacs buffer, instead of suspending Emacs and executing
  957. commands in your login shell.  Normally, `C-z' is bound to the function
  958. `suspend-emacs' (when not using the X Window System), but you can
  959. change `C-z' to invoke an interactive subshell within Emacs, by binding
  960. it to `shell' as follows:
  961.  
  962.      M-x global-set-key RET C-z shell RET
  963.  
  964. `global-set-key' reads the command name after the key.   After you
  965. press the key, a message like this appears so that you can confirm that
  966. you are binding the key you want:
  967.  
  968.      Set key C-z to command:
  969.  
  970.    You can redefine function keys and mouse events in the same way; just
  971. type the function key or click the mouse when it's time to specify the
  972. key to rebind.
  973.  
  974.    You can rebind a key that contains more than one event in the same
  975. way.  Emacs keeps reading the key to rebind until it is a complete key
  976. (that is, not a prefix key).  Thus, if you type `C-f' for KEY, that's
  977. the end; the minibuffer is entered immediately to read CMD.  But if you
  978. type `C-x', another character is read; if that is `4', another
  979. character is read, and so on.  For example,
  980.  
  981.      M-x global-set-key RET C-x 4 $ spell-other-window RET
  982.  
  983. redefines `C-x 4 $' to run the (fictitious) command
  984. `spell-other-window'.
  985.  
  986.    The two-character keys consisting of `C-c' followed by a letter are
  987. reserved for user customizations.  Lisp programs are not supposed to
  988. define these keys, so the bindings you make for them will be available
  989. in all major modes and will never get in the way of anything.
  990.  
  991.    You can remove the global definition of a key with
  992. `global-unset-key'.  This makes the key "undefined"; if you type it,
  993. Emacs will just beep.  Similarly, `local-unset-key' makes a key
  994. undefined in the current major mode keymap, which makes the global
  995. definition (or lack of one) come back into effect in that major mode.
  996.  
  997.    If you have redefined (or undefined) a key and you subsequently wish
  998. to retract the change, undefining the key will not do the job--you need
  999. to redefine the key with its standard definition.  To find the name of
  1000. the standard definition of a key, go to a Fundamental mode buffer and
  1001. use `C-h c'.  The documentation of keys in this manual also lists their
  1002. command names.
  1003.  
  1004.    If you want to prevent yourself from invoking a command by mistake,
  1005. it is better to disable the command than to undefine the key.  A
  1006. disabled command is less work to invoke when you really want to.  *Note
  1007. Disabling::.
  1008.  
  1009. 
  1010. File: emacs,  Node: Init Rebinding,  Next: Function Keys,  Prev: Rebinding,  Up: Key Bindings
  1011.  
  1012. Rebinding Keys in Your Init File
  1013. --------------------------------
  1014.  
  1015.    If you have a set of key bindings that you like to use all the time,
  1016. you can specify them in your `.emacs' file by using their Lisp syntax.
  1017.  
  1018.    The simplest method for doing this works for ASCII characters and
  1019. Meta-modified ASCII characters only.  This method uses a string to
  1020. represent the key sequence you want to rebind.  For example, here's how
  1021. to bind `C-z' to `shell':
  1022.  
  1023.      (global-set-key "\C-z" 'shell)
  1024.  
  1025. This example uses a string constant containing one character, `C-z'.
  1026. The single-quote before the command name, `shell', marks it as a
  1027. constant symbol rather than a variable.  If you omit the quote, Emacs
  1028. would try to evaluate `shell' immediately as a variable.  This probably
  1029. causes an error; it certainly isn't what you want.
  1030.  
  1031.    Here is another example that binds a key sequence two characters
  1032. long:
  1033.  
  1034.      (global-set-key "\C-xl" 'make-symbolic-link)
  1035.  
  1036.    When the key sequence includes function keys or mouse button events,
  1037. or non-ASCII characters such as `C-=' or `H-a', you must use the more
  1038. general method of rebinding, which uses a vector to specify the key
  1039. sequence.
  1040.  
  1041.    The way to write a vector in Emacs Lisp is with square brackets
  1042. around the vector elements.  Use spaces to separate the elements.  If an
  1043. element is a symbol, simply write the symbol's name--no other
  1044. delimiters or punctuation are needed.  If a vector element is a
  1045. character, write it as a Lisp character constant: `?' followed by the
  1046. character as it would appear in a string.
  1047.  
  1048.    Here are examples of using vectors to rebind `C-=' (a control
  1049. character outside of ASCII), `H-a' (a Hyper character; ASCII doesn't
  1050. have Hyper at all); f7 (a function key), and `C-Mouse-1' (a
  1051. keyboard-modified mouse button):
  1052.  
  1053.      (global-set-key [?\C-=] 'make-symbolic-link)
  1054.      (global-set-key [?\H-a] 'make-symbolic-link)
  1055.      (global-set-key [f7] 'make-symbolic-link)
  1056.      (global-set-key [C-mouse-1] 'make-symbolic-link)
  1057.  
  1058.    You can use a vector for the simple cases too.  Here's how to rewrite
  1059. the first two examples, above, to use vectors:
  1060.  
  1061.      (global-set-key [?\C-z] 'shell)
  1062.      
  1063.      (global-set-key [?\C-x ?l] 'make-symbolic-link)
  1064.  
  1065. 
  1066. File: emacs,  Node: Function Keys,  Next: Named ASCII Chars,  Prev: Init Rebinding,  Up: Key Bindings
  1067.  
  1068. Rebinding Function Keys
  1069. -----------------------
  1070.  
  1071.    Key sequences can contain function keys as well as ordinary
  1072. characters.  Just as Lisp characters (actually integers) represent
  1073. keyboard characters, Lisp symbols represent function keys.  If the
  1074. function key has a word as its label, then that word is also the name of
  1075. the corresponding Lisp symbol.  Here are the conventional Lisp names for
  1076. common function keys:
  1077.  
  1078. `left', `up', `right', `down'
  1079.      Cursor arrow keys.
  1080.  
  1081. `begin', `end', `home', `next', `prior'
  1082.      Other cursor repositioning keys.
  1083.  
  1084. `select', `print', `execute', `backtab'
  1085. `insert', `undo', `redo', `clearline'
  1086. `insertline', `deleteline', `insertchar', `deletechar',
  1087.      Miscellaneous function keys.
  1088.  
  1089. `f1', `f2', ... `f35'
  1090.      Numbered function keys (across the top of the keyboard).
  1091.  
  1092. `kp-add', `kp-subtract', `kp-multiply', `kp-divide'
  1093. `kp-backtab', `kp-space', `kp-tab', `kp-enter'
  1094. `kp-separator', `kp-decimal', `kp-equal'
  1095.      Keypad keys (to the right of the regular keyboard), with names or
  1096.      punctuation.
  1097.  
  1098. `kp-0', `kp-1', ... `kp-9'
  1099.      Keypad keys with digits.
  1100.  
  1101. `kp-f1', `kp-f2', `kp-f3', `kp-f4'
  1102.      Keypad PF keys.
  1103.  
  1104.    These names are conventional, but some systems (especially when using
  1105. X windows) may use different names.  To make certain what symbol is used
  1106. for a given function key on your terminal, type `C-h c' followed by
  1107. that key.
  1108.  
  1109.    A key sequence which contains function key symbols (or anything but
  1110. ASCII characters) must be a vector rather than a string.  The vector
  1111. syntax uses spaces between the elements, and square brackets around the
  1112. whole vector.  Thus, to bind function key `f1' to the command `rmail',
  1113. write the following:
  1114.  
  1115.      (global-set-key [f1] 'rmail)
  1116.  
  1117. To bind the right-arrow key to the command `forward-char', you can use
  1118. this expression:
  1119.  
  1120.      (global-set-key [right] 'forward-char)
  1121.  
  1122. This uses the Lisp syntax for a vector containing the symbol `right'.
  1123. (This binding is present in Emacs by default.)
  1124.  
  1125.    *Note Init Rebinding::, for more information about using vectors for
  1126. rebinding.
  1127.  
  1128.    You can mix function keys and characters in a key sequence.  This
  1129. example binds `C-x NEXT' to the command `forward-page'.
  1130.  
  1131.      (global-set-key [?\C-x next] 'forward-page)
  1132.  
  1133. where `?\C-x' is the Lisp character constant for the character `C-x'.
  1134. The vector element `next' is a symbol and therefore does not take a
  1135. question mark.
  1136.  
  1137.    You can use the modifier keys CTRL, META, HYPER, SUPER, ALT and
  1138. SHIFT with function keys.  To represent these modifiers, add the
  1139. strings `C-', `M-', `H-', `s-', `A-' and `S-' at the front of the
  1140. symbol name.  Thus, here is how to make `Hyper-Meta-RIGHT' move forward
  1141. a word:
  1142.  
  1143.      (global-set-key [H-M-right] 'forward-word)
  1144.  
  1145.